//
//  HXTFLInfoCell.m
//  掌上宏力
//
//  Created by admin on 2017/6/14.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "HXTFLInfoCell.h"
#import "HXTFLInfoModel.h"

@interface HXTFLInfoCell ()

@property (nonatomic,weak) UILabel *beginDateLab;
@property (nonatomic,weak) UILabel *endDateLab;
@property (nonatomic,weak) UILabel *amountLab;

@end

@implementation HXTFLInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        CGFloat left_dis = 15;
        CGFloat width = kScreenW-left_dis-40;
        CGFloat height = 30;
        
        UILabel *beginLab = [Factory createLabelWithFrame:CGRectMake(left_dis, 5, width, height) fontSize:16];
        [self.contentView addSubview:beginLab];
        self.beginDateLab = beginLab;
        
        UILabel *endLab = [Factory createLabelWithFrame:CGRectMake(left_dis, beginLab.bottom, width, height) fontSize:16];
        [self.contentView addSubview:endLab];
        self.endDateLab = endLab;
        
        UILabel *amountL = [Factory createLabelWithFrame:CGRectMake(left_dis, endLab.bottom, width, height) fontSize:16];
        [self.contentView addSubview:amountL];
        self.amountLab = amountL;
    }
    return self;
}
-(void)setInfoModel:(HXTFLInfoModel *)infoModel{
    NSString *beginStr = infoModel.beginDate;
    NSString *endStr = infoModel.endDate;
    NSString *begin = [beginStr substringToIndex:beginStr.length - 10];
    NSString *end = [endStr substringToIndex:endStr.length - 10];
    
    self.beginDateLab.text = [NSString stringWithFormat:@"开始日期：%@",begin];
    self.endDateLab.text = [NSString stringWithFormat:@"截止日期：%@",end];
    self.amountLab.text = [NSString stringWithFormat:@"数量：%@",infoModel.amount];
}
+(instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *cellId = @"cellId";
    HXTFLInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        cell = [[HXTFLInfoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
